package org.cs2340.jellybeanwms.presenters;

import org.cs2340.jellybeanwms.model.*;
import org.cs2340.jellybeanwms.views.*;

/**
 * Our presenter.  Should not know anything about an Android specific thing
 * 
 * @author Robert
 *
 */
public class EnterPersonPresenter {
	/** the view to manipulate */
	private final IEnterPersonView myView;
	/** the model that the presenter pulls data from */
	private final IModel myModel;
	
	/**
	 * Make the presenter
	 * @param view the view to use
	 * @param model the model to use
	 */
	public EnterPersonPresenter(IEnterPersonView view, IModel model) {
		myView = view;
		myModel = model;
	}
	
	/**
	 * Handle the accept button click in the ui,
	 * Make a new person, add it to the model, and
	 * ask the view to go to the next screen.
	 * 
	 * @param name the name of the person
	 * @param uid the id of the person
	 * @param email the email of the person
	 */
	public void onAddPersonClick(String name, String uid, String email) {
		myModel.addPerson(new Person(name, uid, email));
		myView.advance();
	}

	/**
	 * Handle a cancel button click in the ui.
	 * Just advance to the next screen, but don't
	 * do anything to the model.
	 */
	public void onCancelAddPersonClick() {
		myView.advance();
		
	}

}
